<template>
  <!-- 表单 -->
  <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="题目ID：">
      <el-input v-model="formInline.user" placeholder="" clearable />
    </el-form-item>
    <el-form-item label="年级：">
      <el-select v-model="formInline.region" placeholder="" clearable>
        <el-option label="Zone one" value="shanghai" />
        <el-option label="Zone two" value="beijing" />
      </el-select>
    </el-form-item>
    <el-form-item label="学科：">
      <el-select v-model="formInline.region" placeholder="" clearable>
        <el-option label="Zone one" value="shanghai" />
        <el-option label="Zone two" value="beijing" />
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">添加</el-button>
      <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>
  </el-form>

  <!-- 列表 -->
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column prop="id" label="ID" width="180" />
    <el-table-column prop="subjectId" label="学科" />
    <el-table-column prop="4" label="名称" />
    <el-table-column prop="3" label="创建时间" />
    <el-table-column prop="1" label="操作" />
  </el-table>
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue'
import { probPage, type ProbParamsType, type ProbItemType } from '@/api/paper'  // 这是获取题目列表的接口


const formInline = reactive({
  user: '',
  region: '',
  date: '',
})
//请求列表的参数
const params = ref<ProbParamsType>({
  id: null,
  questionType: null,
  level: null,
  subjectId: null,
  pageIndex: 1,
  pageSize: 10
})
const tableData = ref<ProbItemType[]>([])
//请求题目列表的借口
function getProbList() {
  probPage(params.value).then(res => {
    console.log(res, "probList");
    if (res.code === 1) {
      tableData.value = (res.response?.list as ProbItemType[])
    }
  })
}
getProbList()

//请求学科列表
const onSubmit = () => {
  console.log('submit!')
}
</script>

<style>
.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}
</style>
